clc
clear
x = linspace(-4,4,1000);
sig1 = exp(-pi*x.*x);
plot(x,sig1);title('Original Signal')

noise1=cos(2*pi*((x.^2)/2-(4.*x)));
noise1(x<=-4|x>=4)=0;
%figure,plot(x,noise1);

sig=sig1+noise1;
figure,plot(x,sig),axis([-4 4 0 2]);title('Noisy Signal');

F = fft(sig);
Ts = x(2)-x(1);
N = length(x);
W = linspace(-N/2,N/2,N)/(N);
figure,plot(W,fftshift(abs(F)));title('Fourier Transform of Noisy Signal');

a = 0.42;
FRT1 = abs(fracF(sig,a));
figure,plot(x,FRT1);title('FRT with a = 0.5')
FRT1(x>=1.5)=0;
figure,plot(x,abs(FRT1));title('Truncated FRT with a = 0.5');

FRT2 = abs(fracF(abs(FRT1),-1));
figure,plot(x,FRT2);title('FRT with a = -0.5');
FRT2(x<=-0.05 | x>=0.05)=0;
FRT3 = abs(fracF(FRT2,a));
figure,plot(x,FRT3);title('Recovered signal');